import 'package:flutter/material.dart';
import '../model/User.dart';
import 'JvtdUserReducer.dart';
import 'JvtdThemeDataReducer.dart';
import 'JvtdLocaleReducer.dart';

// 全局Redux store 的对象，保存State数据
class JvtdState{
  User userInfo;//用户信息

  ThemeData themeData;//主题

  Locale locale;//语言

  Locale platformLocale;//本机语言

  JvtdState({this.userInfo,this.themeData,this.locale});
}

///创建 Reducer
///源码中 Reducer 是一个方法 typedef State Reducer<State>(State state, dynamic action);
///我们自定义了 appReducer 用于创建 store
JvtdState appReducer(JvtdState state, action) {
  return JvtdState(
    ///通过自定义 JvtdUserReducer 将 JvtdState 内的 userInfo 和 action 关联在一起
    userInfo: JvtdUserReducer(state.userInfo, action),

    ///通过自定义 JvtdThemeDataReducer 将 JvtdState 内的 themeData 和 action 关联在一起
    themeData: JvtdThemeDataReducer(state.themeData, action),

    ///通过自定义 JvtdLocaleReducer 将 JvtdState 内的 locale 和 action 关联在一起
    locale: JvtdLocaleReducer(state.locale, action),
  );
}